#!/sbin/openrc-run

name="vaultwarden"
description="Vaultwarden daemon"
supervisor="supervise-daemon"
command="/usr/bin/vaultwarden"
command_user="${command_user:-vaultwarden:vaultwarden}"
directory="${DATA_FOLDER:-/var/lib/vaultwarden}"

depend() {
	need localmount net
	after firewall
}

start_pre() {
	checkpath -m 0750 -d -o "$command_user" "$directory"

	if [ -n "$logdir" ]; then
		checkpath -m 0750 -d -o "$command_user" "$logdir"
	fi

	if [ -n "$output_log" ]; then
		checkpath -m 0640 -f -o "$command_user" "$output_log"
	fi

	if [ -n "$error_log" ]; then
		checkpath -m 0640 -f -o "$command_user" "$error_log"
	fi
}
